#ifndef BUILTINS_H
#define BUILTINS_H 1

#include "../main.h"
#include "../tag.h"
#include "../var.h"
#include "../db.h"
#include "../template.h"
#include "../url.h"

#ifdef ENABLE_PTHREADS
# include <pthread.h>
# define __BLTIN_RT __thread
#else
# define __BLTIN_RT static
#endif
#define __BLTIN_ST static const
#define __BLTIN_VAR const var_t

#ifdef USE_BUILTIN_BLOG
# include "blog.h"
# define INIT_BUILTIN_BLOG INIT_BUILTIN(blog_var)
#else
# define INIT_BUILTIN_BLOG
#endif

#ifdef USE_BUILTIN_DATE
# include "date.h"
# define INIT_BUILTIN_DATE INIT_BUILTIN(date_var)
#else
# define INIT_BUILTIN_DATE
#endif

#ifdef USE_BUILTIN_TMPL
# include "template.h"
# define INIT_BUILTIN_TMPL INIT_BUILTIN(tmpl_var)
#else
# define INIT_BUILTIN_TMPL
#endif

#ifdef USE_BUILTIN_VERSION
# include "version.h"
# define INIT_BUILTIN_VERSION INIT_BUILTIN(version_var) \
                              INIT_BUILTIN(gccver_var) \
                              INIT_BUILTIN(buildtime_var) \
                              INIT_BUILTIN(buildhost_var) \
                              INIT_BUILTIN(buildtarget_var) \
                              INIT_BUILTIN(buildfeatures_var)
#else
# define INIT_BUILTIN_VERSION
#endif

#define INIT_BUILTIN(x) extern __BLTIN_VAR x; register_var(&x);
#ifndef BUILTINS
#define BUILTINS \
        INIT_BUILTIN_DATE \
        INIT_BUILTIN_VERSION \
        INIT_BUILTIN_BLOG \
        INIT_BUILTIN_TMPL
#endif

#endif
